package com.gengealogy.net.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.gengealogy.net.dao.UserDao;
import com.gengealogy.net.po.User;
import com.gengealogy.net.service.UserService;


@Service("userService")
@Transactional
public class UserServiceImpl implements UserService{

	// 注入UserDao
		@Autowired
		private UserDao userDao;
		public UserDao getUserDao() {
			return userDao;
		}

		public void setUserDao(UserDao userDao) {
			this.userDao = userDao;
		}

		// 通过账号和密码查询用户
		@Override
		public User findUser(String username, String password) {
			User user = this.userDao.findUser(username, password);
			return user;
		}
		
		@Override
		public int register(User user){
			return userDao.register(user);
		}

		@Override
		public User getUserById(int user_id) {
			// TODO Auto-generated method stub
			return userDao.getUserById(user_id);
		}

		@Override
		public int updateUser(User user){
			// TODO Auto-generated method stub
			return userDao.updateUser(user);
		}

		@Override
		public int deleteUser(int user_id){
			// TODO Auto-generated method stub
			return userDao.deleteUser(user_id);
		}

		@Override
		public List<User> getUser() {
			// TODO Auto-generated method stub
			return userDao.getUser();
		}
	
		@Override
	    public int userUpdate(User user) {
	      // TODO Auto-generated method stub
	      return userDao.userUpdate(user);
	    }

		@Override
		public int getUserByName(String username) {
			// TODO Auto-generated method stub
			return userDao.getUserByName(username);
		}
}
